package util;

import java.util.Stack;

/**
 * A First-in First-out queue. It is used to register
 * racers whose number plates cannot be read and needs to be entered at a later
 * occasion.
 * 
 * @author team07
 * 
 */
public class FifoQueue {

	private Stack<String> queue;

	/**
	 * Constructor for FifoQueue. Initiates the internal 
	 * representation of the queue.
	 */
	public FifoQueue() {
		queue = new Stack<String>();
	}

	/**
	 * Checks if the queue is empty
	 * 
	 * @return True if it's empty, otherwise false
	 */
	public boolean isEmpty() {
		return queue.isEmpty();
	}

	/**
	 * Returns the last element of the Queue
	 * 
	 * @return The last string
	 */
	public String pop() {
		return queue.remove(0);
	}

	/**
	 * Inserts an element at the start of the queue
	 * 
	 * @param item
	 *            The String to be pushed on to the top.
	 */
	public void push(String item) {
		queue.push(item);
	}

	/**
	 * Gives a string representation of the queue.
	 * 
	 * @return The string representation.
	 */
	public String toString() {
		String content = "";
		for (String element : queue) {
			content += element + "\n";
		}
		return content;
	}
}
